11

What Is an Algorithm?

11

As I had mentioned earlier in this chapter, an algorithm has several components,

but the key component is the repetition—​the ability to do something again and again

in a controlled manner.

The last four words are significant—​it is as important for an algorithm to know

how to repeat, as it is to understand when to stop. In the previous example, if it

keeps pasting the copied rows without stopping that would make the new spreadsheet

unnaturally big and the boss very unhappy. The problem of combining spreadsheets

into one is discussed in more detail with instructions on how to convert this algorithm

to real code in Chapter 6.

The next few chapters will develop this concept of algorithms with more complex

and interesting problems. The art of developing an algorithm cannot be taught. It is a

little bit like swimming—​it is a skill that can only be learned by plunging yourself in

the water. The examples you will find in this book will hopefully serve you well as a

life jacket as they take you through a variety of situations from everyday life.